<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>流程实例列表</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
var showProcInstBox;
function viewInstanceRequest(){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;		
	}
	if (!showProcInstBox){
		showProcInstBox = new PopupBox('showProcInstBox','流程实例信息',{width:'900px',height:'500px',top:'10px',scroll:'yes'});		
	}	
	var url = "index?WfProcessInstanceView&actionType=prepareDisplay&WFIP_ID="+$('#WFIP_ID').val() +"&WFP_ID="+$('#WFP_ID').val();
	showProcInstBox.sendRequest(url);
}
var selectProcBox;
function selectProcRequest(){
	if (!selectProcBox){
		selectProcBox = new PopupBox('selectProcBox','选择流程',{size:'big',height:'456px',top:'10px'});		
	}
	var url = 'index?WfProcessDefineSelect&targetId=CUR_WFP_ID&targetName=CUR_WFP_NAME';
	selectProcBox.sendRequest(url);
}

function suspendInstance(){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;		
	}
	postRequest('form1',{actionType:'suspendInstance',onComplete:function(responseText){
		if (responseText == 'success'){
			doSubmit({actionType:'prepareDisplay'});
		}
	}})	
}

function resumeInstance(){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;		
	}
	postRequest('form1',{actionType:'resumeInstance',onComplete:function(responseText){
		if (responseText == 'success'){
			doSubmit({actionType:'prepareDisplay'});
		}
	}})		
}

function terminateInstance(){
	if (!isSelectedRow()){
		writeErrorMsg('请先选中一条记录!');
		return;		
	}
	postRequest('form1',{actionType:'terminateInstance',onComplete:function(responseText){
		if (responseText == 'success'){
			doSubmit({actionType:'prepareDisplay'});
		}
	}})		
}
function controlButton(){
	var instState = $("#instanceState").val();
	if ("running" == instState){
		disableButton('resumeImgBtn');
		enableButton('suspendImgBtn');
	}else{
		disableButton('suspendImgBtn');
		enableButton('resumeImgBtn');
	}
}
function resetWfpRequest(){
	$("#CUR_WFP_ID").val("");
	$("#CUR_WFP_NAME").val("");
	doSubmit({actionType:'prepareDisplay'});	
}
</script>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<div id="__ParamBar__" style="float: right;">
流程名称
<input name="CUR_WFP_NAME" type="text" class="text" id="CUR_WFP_NAME" ondblclick="selectProcRequest()" value="<%=pageBean.inputValue("CUR_WFP_NAME")%>" size="16" maxlength="16" readonly="readonly" />
<input name="CUR_WFP_ID" type="hidden" id="CUR_WFP_ID" value="<%=pageBean.inputValue("CUR_WFP_ID")%>" /><img src="images/query.gif" width="16" height="16" onclick="selectProcRequest()" style="cursor:pointer" />&nbsp;&nbsp;<input type="button" name="button" id="button" value="重置" class="formbutton" onclick="resetWfpRequest()" />
</div>
<div id="__ToolBar__">
<table border="0" cellpadding="0" cellspacing="1">
<tr>
	<td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="V" class="bartdx" align="center" onClick="doSubmit({actionType:'prepareDisplay'})"><input value="&nbsp;" type="button" class=refreshImgBtn title="刷新" />刷新</td>
	<td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="V" class="bartdx" align="center" onClick="viewInstanceRequest()"><input value="&nbsp;" type="button" class="detailImgBtn" title="详情" />详情</td>
	<td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="S" class="bartdx" align="center" onClick="suspendInstance()"><input id="suspendImgBtn" value="&nbsp;" type="button" class="suspendImgBtn" title="挂起流程" />挂起流程</td>
	<td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="R" class="bartdx" align="center" onClick="resumeInstance()"><input id="resumeImgBtn" value="&nbsp;" type="button" class="resumeImgBtn" title="重启流程" />重启流程</td>
	<td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="D" class="bartdx" align="center" onClick="terminateInstance()"><input id="stopImgBtn" value="&nbsp;" type="button" class="stopImgBtn" title="终止流程" />终止流程</td>
	<td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="W" class="bartdx" align="center" onClick="doSubmit({actionType:'bactToStat'})"><input value="&nbsp;" type="button" class="relateImgBtn" title="查看统计" />查看统计</td>    
	<td onmouseover="onMover(this);" onmouseout="onMout(this);" hotKey="B" class="bartdx" align="center" onClick="goToMain();"><input value="&nbsp;" type="button" class="backImgBtn" title="返回" />返回</td>        
</tr>
</table>
</div>
<ec:table 
form="form1"
var="row"
items="pageBean.rsList" csvFileName="流程实例列表.csv"
retrieveRowsCallback="process" xlsFileName="流程实例列表.xls"
useAjax="true" sortable="true"
doPreload="false" toolbarContent="navigation|pagejump |pagesize |export|extend|status"
width="100%" rowsDisplayed="10"
listWidth="100%" 
height="400px" 
>
<ec:row styleClass="odd" ondblclick="viewInstanceRequest()" oncontextmenu="selectRow(this,{WFIP_ID:'${row.WFIP_ID}',WFP_ID:'${row.WFP_ID}',WFIP_BUSINESS_ID:'${row.WFIP_BUSINESS_ID}',instanceState:'${row.WFIP_STATUS}'});controlButton();refreshConextmenu()" onclick="selectRow(this,{WFIP_ID:'${row.WFIP_ID}',WFP_ID:'${row.WFP_ID}',WFIP_BUSINESS_ID:'${row.WFIP_BUSINESS_ID}',instanceState:'${row.WFIP_STATUS}'});controlButton();">
	<ec:column width="50" style="text-align:center" property="_0" title="序号" value="${GLOBALROWCOUNT}" />
	<ec:column width="140" property="WFP_NAME" title="流程名称"   />
	<ec:column width="260" property="WFIP_TITLE" title="业务标题"   />
	<ec:column width="80" property="WFIP_STATUS" title="状态"   />
	<ec:column width="80" property="WFIP_OPERATER_NAME" title="提交人"   />
	<ec:column width="90" property="WFIP_OPERATER_TIME" title="提交时间"  cell="date" format="yyyy-MM-dd HH:mm" />
</ec:row>
</ec:table>
<input type="hidden" name="WFIP_ID" id="WFIP_ID" value="" />
<input type="hidden" name="WFP_ID" id="WFP_ID" value="" />
<input type="hidden" name="WFIP_BUSINESS_ID" id="WFIP_BUSINESS_ID" value="" />
<input type="hidden" name="instanceState" id="instanceState" value="" />
<input type="hidden" name="actionType" id="actionType" />
<script language="JavaScript">
setRsIdTag('WFIP_ID');
var ectableMenu = new EctableMenu('contextMenu','ec_table');
</script>
</form>
</body>
</html>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
